home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-04-18 | 15.1 KB | 777 lines | [TEXT/MPS ] |
- ;
- ; File: MIDI.a
- ;
- ; Contains: MIDI Manager Interfaces.
- ;
- ; Version: Technology: System 7.5
- ; Package: Universal Interfaces 2.1ß1 in “MPW Prerelease” on ETO #17
- ;
- ; Copyright: © 1984-1995 by Apple Computer, Inc.
- ; All rights reserved.
- ;
- ; Bugs?: If you find a problem with this file, use the Apple Bug Reporter
- ; stack. Include the file and version information (from above)
- ; in the problem description and send to:
- ; Internet: apple.bugs@applelink.apple.com
- ; AppleLink: APPLE.BUGS
- ;
- ;
-
- IF &TYPE('__MIDI__') = 'UNDEFINED' THEN
- __MIDI__ SET 1
-
-
- IF &TYPE('__ERRORS__') = 'UNDEFINED' THEN
- include 'Errors.a'
- ENDIF
- ; include 'ConditionalMacros.a' ;
-
- IF &TYPE('__TYPES__') = 'UNDEFINED' THEN
- include 'Types.a'
- ENDIF
-
- IF &TYPE('__MIXEDMODE__') = 'UNDEFINED' THEN
- include 'MixedMode.a'
- ENDIF
-
- midiToolNum EQU 4 ;tool number of MIDI Manager for SndDispVersion call
- midiMaxNameLen EQU 31 ;maximum number of characters in port and client names
- ; Time formats
- midiFormatMSec EQU 0 ;milliseconds
- midiFormatBeats EQU 1 ;beats
- midiFormat24fpsBit EQU 2 ;24 frames/sec.
- midiFormat25fpsBit EQU 3 ;25 frames/sec.
- midiFormat30fpsDBit EQU 4 ;30 frames/sec. drop-frame
- midiFormat30fpsBit EQU 5 ;30 frames/sec.
- midiFormat24fpsQF EQU 6 ;24 frames/sec. longInt format
- midiFormat25fpsQF EQU 7 ;25 frames/sec. longInt format
- midiFormat30fpsDQF EQU 8 ;30 frames/sec. drop-frame longInt format
- midiFormat30fpsQF EQU 9 ;30 frames/sec. longInt format
- midiInternalSync EQU 0 ;internal sync
- midiExternalSync EQU 1 ;external sync
- ; Port types
- midiPortTypeTime EQU 0 ;time port
- midiPortTypeInput EQU 1 ;input port
- midiPortTypeOutput EQU 2 ;output port
- midiPortTypeTimeInv EQU 3 ;invisible time port
- ; OffsetTimes
- midiGetEverything EQU $7FFFFFFF ;get all packets, regardless of time stamps
- midiGetNothing EQU $80000000 ;get no packets, regardless of time stamps
- midiGetCurrent EQU $00000000 ;get current packets only
-
- ; MIDI data and messages are passed in MIDIPacket records (see below).
- ; The first byte of every MIDIPacket contains a set of flags
- ;
- ; bits 0-1 00 = new MIDIPacket, not continued
- ; 01 = begining of continued MIDIPacket
- ; 10 = end of continued MIDIPacket
- ; 11 = continuation
- ; bits 2-3 reserved
- ;
- ; bits 4-6 000 = packet contains MIDI data
- ;
- ; 001 = packet contains MIDI Manager message
- ;
- ; bit 7 0 = MIDIPacket has valid stamp
- ; 1 = stamp with current clock
- ;
- midiContMask EQU $03
- midiNoCont EQU $00
- midiStartCont EQU $01
- midiMidCont EQU $03
- midiEndCont EQU $02
- midiTypeMask EQU $70
- midiMsgType EQU $00
- midiMgrType EQU $10
- midiTimeStampMask EQU $80
- midiTimeStampCurrent EQU $80
- midiTimeStampValid EQU $00
- ; MIDIPacket command words (the first word in the data field for midiMgrType messages)
- midiOverflowErr EQU $0001
- midiSCCErr EQU $0002
- midiPacketErr EQU $0003
- ;all command words less than this value are error indicators
- midiMaxErr EQU $00FF
- ; Valid results to be returned by readHooks
- midiKeepPacket EQU 0
- midiMorePacket EQU 1
- midiNoMorePacket EQU 2
- ; Driver calls
- midiOpenDriver EQU 1
- midiCloseDriver EQU 2
-
- MIDIPacket RECORD 0
- flags ds.b 1 ; offset: $0 (0)
- len ds.b 1 ; offset: $1 (1)
- tStamp ds.l 1 ; offset: $2 (2)
- data ds.b 249 ; offset: $6 (6)
- ORG 256
- sizeof EQU * ; size: $100 (256)
- ENDR
-
- ; typedef struct MIDIPacket MIDIPacket
- ; typedef MIDIPacket *MIDIPacketPtr
- MIDIClkInfo RECORD 0
- syncType ds.w 1 ; offset: $0 (0) ;synchronization external/internal
- curTime ds.l 1 ; offset: $2 (2) ;current value of port's clock
- format ds.w 1 ; offset: $6 (6) ;time code format
- sizeof EQU * ; size: $8 (8)
- ENDR
-
- ; typedef struct MIDIClkInfo MIDIClkInfo
- MIDIIDRec RECORD 0
- clientID ds.l 1 ; offset: $0 (0)
- portID ds.l 1 ; offset: $4 (4)
- sizeof EQU * ; size: $8 (8)
- ENDR
-
- ; typedef struct MIDIIDRec MIDIIDRec
- MIDIPortInfo RECORD 0
- portType ds.w 1 ; offset: $0 (0) ;type of port
- timeBase ds MIDIIDRec ; offset: $2 (2) ;MIDIIDRec for time base
- numConnects ds.w 1 ; offset: $A (10) ;number of connections
- cList ds MIDIIDRec ; offset: $C (12) ;ARRAY [1..numConnects] of MIDIIDRec
- sizeof EQU * ; size: $14 (20)
- ENDR
-
- ; typedef struct MIDIPortInfo MIDIPortInfo
- ; typedef MIDIPortInfo *MIDIPortInfoPtr, **MIDIPortInfoHdl, **MIDIPortInfoHandle
- MIDIPortParams RECORD 0
- portID ds.l 1 ; offset: $0 (0) ;ID of port, unique within client
- portType ds.w 1 ; offset: $4 (4) ;Type of port - input, output, time, etc.
- timeBase ds.w 1 ; offset: $6 (6) ;refnum of time base, 0 if none
- offsetTime ds.l 1 ; offset: $8 (8) ;offset for current time stamps
- readHook ds.l 1 ; offset: $C (12) ;routine to call when input data is valid
- refCon ds.l 1 ; offset: $10 (16) ;refcon for port (for client use)
- initClock ds MIDIClkInfo ; offset: $14 (20) ;initial settings for a time base
- name ds.l 64 ; offset: $1C (28) ;name of the port, This is a real live string, not a ptr.
- sizeof EQU * ; size: $11C (284)
- ENDR
-
- ; typedef struct MIDIPortParams MIDIPortParams
- ; typedef MIDIPortParams *MIDIPortParamsPtr
- MIDIIDList RECORD 0
- numIDs ds.w 1 ; offset: $0 (0)
- list ds.l 1 ; offset: $2 (2)
- sizeof EQU * ; size: $6 (6)
- ENDR
-
- ; typedef struct MIDIIDList MIDIIDList
- ; typedef MIDIIDList *MIDIIDListPtr, **MIDIIDListHdl, **MIDIIDListHandle
- ;
- ; pascal NumVersion MIDIVersion(void)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIVersion
- dc.w $203C
- dc.w $0000
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIVersion
- ENDIF
-
- ;
- ; pascal OSErr MIDISignIn(OSType clientID, long refCon, Handle icon, ConstStr255Param name)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDISignIn
- dc.w $203C
- dc.w $0004
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDISignIn
- ENDIF
-
- ;
- ; pascal void MIDISignOut(OSType clientID)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDISignOut
- dc.w $203C
- dc.w $0008
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDISignOut
- ENDIF
-
- ;
- ; pascal MIDIIDListHandle MIDIGetClients(void)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIGetClients
- dc.w $203C
- dc.w $000C
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIGetClients
- ENDIF
-
- ;
- ; pascal void MIDIGetClientName(OSType clientID, Str255 name)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIGetClientName
- dc.w $203C
- dc.w $0010
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIGetClientName
- ENDIF
-
- ;
- ; pascal void MIDISetClientName(OSType clientID, ConstStr255Param name)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDISetClientName
- dc.w $203C
- dc.w $0014
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDISetClientName
- ENDIF
-
- ;
- ; pascal MIDIIDListHandle MIDIGetPorts(OSType clientID)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIGetPorts
- dc.w $203C
- dc.w $0018
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIGetPorts
- ENDIF
-
- ;
- ; pascal OSErr MIDIAddPort(OSType clientID, short BufSize, short *refnum, MIDIPortParamsPtr init)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIAddPort
- dc.w $203C
- dc.w $001C
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIAddPort
- ENDIF
-
- ;
- ; pascal MIDIPortInfoHandle MIDIGetPortInfo(OSType clientID, OSType portID)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIGetPortInfo
- dc.w $203C
- dc.w $0020
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIGetPortInfo
- ENDIF
-
- ;
- ; pascal OSErr MIDIConnectData(OSType srcClID, OSType srcPortID, OSType dstClID, OSType dstPortID)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIConnectData
- dc.w $203C
- dc.w $0024
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIConnectData
- ENDIF
-
- ;
- ; pascal OSErr MIDIUnConnectData(OSType srcClID, OSType srcPortID, OSType dstClID, OSType dstPortID)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIUnConnectData
- dc.w $203C
- dc.w $0028
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIUnConnectData
- ENDIF
-
- ;
- ; pascal OSErr MIDIConnectTime(OSType srcClID, OSType srcPortID, OSType dstClID, OSType dstPortID)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIConnectTime
- dc.w $203C
- dc.w $002C
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIConnectTime
- ENDIF
-
- ;
- ; pascal OSErr MIDIUnConnectTime(OSType srcClID, OSType srcPortID, OSType dstClID, OSType dstPortID)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIUnConnectTime
- dc.w $203C
- dc.w $0030
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIUnConnectTime
- ENDIF
-
- ;
- ; pascal void MIDIFlush(short refnum)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIFlush
- dc.w $203C
- dc.w $0034
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIFlush
- ENDIF
-
- ;
- ; pascal ProcPtr MIDIGetReadHook(short refnum)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIGetReadHook
- dc.w $203C
- dc.w $0038
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIGetReadHook
- ENDIF
-
- ;
- ; pascal void MIDISetReadHook(short refnum, ProcPtr hook)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDISetReadHook
- dc.w $203C
- dc.w $003C
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDISetReadHook
- ENDIF
-
- ;
- ; pascal void MIDIGetPortName(OSType clientID, OSType portID, Str255 name)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIGetPortName
- dc.w $203C
- dc.w $0040
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIGetPortName
- ENDIF
-
- ;
- ; pascal void MIDISetPortName(OSType clientID, OSType portID, ConstStr255Param name)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDISetPortName
- dc.w $203C
- dc.w $0044
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDISetPortName
- ENDIF
-
- ;
- ; pascal void MIDIWakeUp(short refnum, long time, long period, MIDITimeUPP timeProc)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIWakeUp
- dc.w $203C
- dc.w $0048
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIWakeUp
- ENDIF
-
- ;
- ; pascal void MIDIRemovePort(short refnum)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIRemovePort
- dc.w $203C
- dc.w $004C
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIRemovePort
- ENDIF
-
- ;
- ; pascal short MIDIGetSync(short refnum)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIGetSync
- dc.w $203C
- dc.w $0050
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIGetSync
- ENDIF
-
- ;
- ; pascal void MIDISetSync(short refnum, short sync)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDISetSync
- dc.w $203C
- dc.w $0054
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDISetSync
- ENDIF
-
- ;
- ; pascal long MIDIGetCurTime(short refnum)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIGetCurTime
- dc.w $203C
- dc.w $0058
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIGetCurTime
- ENDIF
-
- ;
- ; pascal void MIDISetCurTime(short refnum, long time)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDISetCurTime
- dc.w $203C
- dc.w $005C
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDISetCurTime
- ENDIF
-
- ;
- ; pascal void MIDIStartTime(short refnum)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIStartTime
- dc.w $203C
- dc.w $0060
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIStartTime
- ENDIF
-
- ;
- ; pascal void MIDIStopTime(short refnum)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIStopTime
- dc.w $203C
- dc.w $0064
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIStopTime
- ENDIF
-
- ;
- ; pascal void MIDIPoll(short refnum, long offsetTime)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIPoll
- dc.w $203C
- dc.w $0068
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIPoll
- ENDIF
-
- ;
- ; pascal OSErr MIDIWritePacket(short refnum, MIDIPacketPtr packet)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIWritePacket
- dc.w $203C
- dc.w $006C
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIWritePacket
- ENDIF
-
- ;
- ; pascal Boolean MIDIWorldChanged(OSType clientID)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIWorldChanged
- dc.w $203C
- dc.w $0070
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIWorldChanged
- ENDIF
-
- ;
- ; pascal long MIDIGetOffsetTime(short refnum)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIGetOffsetTime
- dc.w $203C
- dc.w $0074
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIGetOffsetTime
- ENDIF
-
- ;
- ; pascal void MIDISetOffsetTime(short refnum, long offsetTime)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDISetOffsetTime
- dc.w $203C
- dc.w $0078
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDISetOffsetTime
- ENDIF
-
- ;
- ; pascal long MIDIConvertTime(short srcFormat, short dstFormat, long time)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIConvertTime
- dc.w $203C
- dc.w $007C
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIConvertTime
- ENDIF
-
- ;
- ; pascal long MIDIGetRefCon(short refnum)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIGetRefCon
- dc.w $203C
- dc.w $0080
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIGetRefCon
- ENDIF
-
- ;
- ; pascal void MIDISetRefCon(short refnum, long refCon)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDISetRefCon
- dc.w $203C
- dc.w $0084
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDISetRefCon
- ENDIF
-
- ;
- ; pascal long MIDIGetClRefCon(OSType clientID)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIGetClRefCon
- dc.w $203C
- dc.w $0088
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIGetClRefCon
- ENDIF
-
- ;
- ; pascal void MIDISetClRefCon(OSType clientID, long refCon)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDISetClRefCon
- dc.w $203C
- dc.w $008C
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDISetClRefCon
- ENDIF
-
- ;
- ; pascal short MIDIGetTCFormat(short refnum)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIGetTCFormat
- dc.w $203C
- dc.w $0090
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIGetTCFormat
- ENDIF
-
- ;
- ; pascal void MIDISetTCFormat(short refnum, short format)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDISetTCFormat
- dc.w $203C
- dc.w $0094
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDISetTCFormat
- ENDIF
-
- ;
- ; pascal void MIDISetRunRate(short refnum, short rate, long time)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDISetRunRate
- dc.w $203C
- dc.w $0098
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDISetRunRate
- ENDIF
-
- ;
- ; pascal Handle MIDIGetClientIcon(OSType clientID)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MIDIGetClientIcon
- dc.w $203C
- dc.w $009C
- dc.w $0004
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MIDIGetClientIcon
- ENDIF
-
- ;
- ; pascal long SndDispVersion(short toolnum)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _SndDispVersion
- dc.w $203C
- dc.w $0000
- dc.w $0000
- dc.w $A800
- EndM
- ELSE
- IMPORT_CFM_FUNCTION SndDispVersion
- ENDIF
-
- ENDIF ; __MIDI__
-